
class Topic < ActiveRecord::Base
  belongs_to :user
  has_many :comments
  validates_presence_of :title, :topic_content
  validates_length_of :title, :maximum =>255
  validates_uniqueness_of :title

  def self.find_on_page(page_num, page_size)
    find(:all, :conditions=>"visible=1", :order=>"created_at desc", :limit=>page_size, :offset=>page_num*page_size)
  end
end
